# Importing necessary modules from cachetools for caching functionality.
from cachetools import TTLCache, cached
# Importing the function to retrieve all roles from the application's authentication module.
from myapp.third.auth.permission import get_all_roles


# Decorator to cache the results of the get_role_list function.
# TTLCache is used with a maximum size of 100 entries and a time-to-live (ttl) of 60 seconds.
@cached(TTLCache(maxsize=100, ttl=60))
# Defines a function to retrieve a list of all role names.
def get_role_list() -> list[str]:
    """获取角色列表"""
    # Initializes an empty list to store the role names.
    ret = []
    # Calls the get_all_roles function to fetch all available roles.
    roles = get_all_roles()
    # Iterates through each role retrieved.
    for role in roles:
        # Appends the 'name' of the current role to the return list.
        ret.append(role['name'])

    # Returns the list of role names.
    return ret
